<?php
/**
 * Created by Benjamin.
 * Date: 2020/4/29
 * Time: 10:46
 */
$server = new Swoole\Server("0.0.0.0", 9502, SWOOLE_PROCESS, SWOOLE_SOCK_UDP);

//监听数据接收事件
$server->on('Packet', function ($server, $data, $clientInfo) {
    echo "udp客户端发送了数据:{$data}\n";
    $server->sendto($clientInfo['address'], $clientInfo['port'], "服务器回复:{$data}");
    var_dump($clientInfo);
});
echo "服务器启动成功\n";
//启动服务器
$server->start();